import random
import time

def sleep(ms):
    time.sleep(ms/1000.)
    
def rand(min, max):
    return random.randint(min, max)
    
def rsleep(min, max):
    r = rand(min, max)
    sleep(r)

HEX = '0123456789abcdef'

def rgb(triplet):
    triplet = triplet.lower()
    return (HEX.index(triplet[0])*16 + HEX.index(triplet[1]),
            HEX.index(triplet[2])*16 + HEX.index(triplet[3]),
            HEX.index(triplet[4])*16 + HEX.index(triplet[5]))
